package za.org.jcicada.comms.impl;

import java.io.IOException;
import java.net.URI;

import za.org.jcicada.comms.IAcceptListener;
import za.org.jcicada.comms.IAcceptor;
import za.org.jcicada.comms.impl.inprocess.InProcessAcceptor;
import za.org.jcicada.comms.impl.katcp.KatcpAcceptor;
import za.org.jcicada.comms.impl.tcp.TcpAcceptor;
import za.org.jcicada.comms.impl.udp.UdpAcceptor;

public class AcceptorFactory {
    
    public static IAcceptor createAcceptor(URI baseLocationURI, IAcceptListener acceptListener) throws IOException {
        if (baseLocationURI.getScheme().equals(TcpAcceptor.TCP)) {
            return new TcpAcceptor(acceptListener, baseLocationURI);
        }
        if (baseLocationURI.getScheme().equals(UdpAcceptor.UDP)) {
            return new UdpAcceptor(acceptListener, baseLocationURI);
        }
        if (baseLocationURI.getScheme().equals(KatcpAcceptor.KATCP)) {
            return new KatcpAcceptor(acceptListener, baseLocationURI);
        }
        if (baseLocationURI.getScheme().equals(InProcessAcceptor.IN_PROCESS)) {
            return new InProcessAcceptor(acceptListener);
        }
        return null;
    }

}
